package com.bili.bili_data_api.util;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Result {

    private Integer code;

    private Map<String, Object> data = new HashMap<String, Object>();

    private Result() {}

    public static Result ok() {
        Result r = new Result();
        r.setCode(2000);//默认2000表示成功
        return r;
    }

    public static Result error() {
        Result r = new Result();
        r.setCode(4000);
        return r;
    }

    public Result code(Integer code){
        this.setCode(code);
        return this;
    }

    public Result data(String key, Object value){
        this.data.put(key, value);
        return this;
    }

}
